version: '3.8'

services:
  backend:
    container_name: backend
    build: 
      context: ./backend
      target: dev
    command: uvicorn main:app --reload --host 0.0.0.0 --port 5000 --use-colors 
             # --log-config=src/logging.dev.yaml
             # --log-config=src/logging.yaml 
             # --log-level trace
             # --log-level [critical|error|warning|info|debug|trace]
    stop_signal: SIGKILL
    volumes:
      - ./backend:/app
    secrets:
      - recaptcha_secret
    ports:
      - 5000:5000
    labels:
      - traefik.enable=true
      - traefik.http.services.backend.loadbalancer.server.port=5000
      - traefik.http.routers.backend.rule=PathPrefix(`/ws/`)
      # - traefik.http.routers.backend.tls=true

  ui:
    container_name: ui
    build: 
      context: ./ui
      target: nodejs
    volumes:
      - ./ui:/app
      - ~/gurren/ui.env:/app/.env
    ports:
      - 8000:8000
    command: ["npm", "run", "dev"]
    stop_signal: SIGKILL   
    labels:
      - traefik.enable=true
      - traefik.http.services.ui.loadbalancer.server.port=8000
      - traefik.http.routers.ui.rule=PathPrefix(`/`)
      # - traefik.http.routers.ui.tls=true
      # - traefik.http.routers.ui.tls.certresolver=letsEncrypt
      # - traefik.http.routers.ui.tls.domains[0].main=archer.docc.ru      

  traefik:
    container_name: traefik
    image: traefik:latest
    ports:
      - 80:80
      - 443:443
      - 8080:8080  # The Web UI (enabled by --api.insecure=true)
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /etc/localtime:/etc/localtime:ro    
      - ./traefik/traefik.yml:/traefik.yml:ro
      - ./traefik/acme.json:/acme.json
    stop_signal: SIGKILL

  mypy: 
    container_name: mypy
    build: 
      context: ./backend
      target: dev
    volumes:
      - ./backend:/app        
    command: watchfiles --filter python 'dmypy run -- src' src    
    # command: watchfiles --filter python 'dmypy run -- --pretty src' src

secrets:
  recaptcha_secret:
    file: ~/gurren/recaptcha_secret.txt
